<@html.doctype/>
<html>
<@html.head>
 
<link rel="stylesheet" type="text/css" href="../includes/styles/skins/Green/layout/css/login.css" />
  <!--此处的脚本用来校验用户名的唯一性-->
  
  <script type="text/javascript">
	$(document).ready(function(){
		$('.tab_dt:first').addClass('active');
		$('.tab_dd:first').css('display','block');
		autoroll();
		hookThumb();
	});
	var i=-1; //第i+1个tab开始
	var offset = 100000; //轮换时间
	var timer = null;
	function autoroll(){
		n = $('.tab_dt').length-1;
		i++;
		if(i > n){
		i = 0;
		}
		slide(i);
		timer = window.setTimeout(autoroll, offset);
		}
	function slide(i){
		$('.tab_dt').eq(i).addClass('active').siblings().removeClass('active');
		$('.tab_dd').eq(i).css('display','block').siblings('.tab_dd').css('display','none');
		
		}
	function hookThumb(){    
		$('.tab_dt').hover(
	  function () {
		if (timer) {
					clearTimeout(timer);
		i = $(this).prevAll().length;
					slide(i); 
				}
	  },
	  function () {		
		timer = window.setTimeout(autoroll, offset);  
		this.blur();            
		return false;
	  }
	); 
	}
</script>
  
  
  <script type="text/javascript">
       function trim(str){
			return str.replace(/^\s*/,"").replace(/\s*$/,"");
		}
        function oneditName() {
        var username=document.getElementById("username2").value;
        $.ajax(
              {
                  url:"${base}/user/nameUniqueCheck.action",
                  dataType:"html",
                  type:"post",
                  data:{username:username},
                  success:function(strValue)
                  {
                      if(strValue==2){ 
                          $("#tip1").html("用户名已存在");
                          return false;           
                     }else
                     {
                     	$("#tip1").html("");
                     	if(strValue==0){ 
                          return true; 
                          }
                          else{
                          return false;
                          }
                        
                     }                                         
                  }
          }) 
          } 
          
        function oneditEmail() {
        var email=document.getElementById("email2").value;
        $.ajax(
              {
                  url:"${base}/user/emailUniqueCheck.action",
                  dataType:"html",
                  type:"post",
                  data:{email:email},
                  success:function(strValue)
                  {
                      if(strValue==2){ 
                          $("#tip2").html("邮箱已被占用");
                          return false;           
                     }else
                     {
                     	$("#tip2").html("");
                     	if(strValue==0){ 
                          return true; 
                          }
                          else{
                          return false;
                          }
                        
                     }                                         
                  }
          }) 
          } 
</script>

 <!--此处的脚本控制注册的数据的一些格式校验-->
 <script type="text/javascript">
$(function(){
		//如果是必填的，则加红星标识.
		$("#registerForm :input.required").each(function(){
			var $required = $("<strong class='high'> *</strong>"); //创建元素
			$(this).parent().append($required); //然后将它追加到文档中
		});
         //文本框失去焦点后
	    $('#registerForm :input').blur(function(){
			 var $parent = $(this).parent();
			 $parent.find(".formtips").remove();
			 //验证用户名
			 if( $(this).is('#username2') ){
					if( this.value=="" || this.value=="  " ||this.value.length < 2 ){
					    var errorMsg = '请输入至少2位的用户名.';
                        $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
					}else{
					    var okMsg = '输入正确.';
					    $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
					}
			 }
		
			 //验证邮件
			 if( $(this).is('#email2') ){
				if( this.value=="" || ( this.value!="" && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value) ) ){
                      var errorMsg = '请输入正确的E-Mail地址.';
					  $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
				}else{
                      var okMsg = '输入正确.';
					  $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
				}
			 }
		
			 //验证密码
			 if( $(this).is('#password2') ){
					if( this.value=="" || this.value.length < 6 ){
					    var errorMsg = '密码太短啦，最少6位';
                        $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
					}else{
					    var okMsg = '输入正确.';
					    $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
					}
			 }
			 
			 //验证确认密码
			 if( $(this).is('#repassword2') ){
					if( this.value=="" || this.value.length <= 0 ){
					    var errorMsg = '再输一次密码';
                        $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
					}
					else{
						
						if(this.value==document.getElementById("password2").value){			
							var okMsg = '输入正确.';
					    	$parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');			
						}
						else{	
					    	var errorMsg = '两次密码输入不一致';
							$parent.append('<span class="formtips onError">'+errorMsg+'</span>');
					    }					   
					}
			 }
			 
		}).keyup(function(){
		   $(this).triggerHandler("blur");
		}).focus(function(){
	  	   $(this).triggerHandler("blur");
		});//end blur
	
		//提交，最终验证。
		 $('#submit').click(function(){
				$("registerForm :input.required").trigger('blur');
				var numError = $('#registerForm .onError').length;
				if(numError>0){
					return false;
				} 
				//else{
				//	alert("注册成功,密码已发到你的邮箱,请查收.");
				//}				
		 });

		//重置
		 $('#cancel').click(function(){
				$(".formtips").remove();
				 $("#tip").html("");
		 });
})
</script>

  
</@html.head>
<body style="padding: 10px">
<@html.header>
  <!--请不要在此处添加内容-->
</@html.header>
<div id="content">
  <div id="banner"> <img src="../includes/styles/skins/Green/layout/images/banner1.png" class="box" title="专业，专注，创新，坚持" alt="专业，专注，创新，坚持"/> </div>
  <div id="hatch">
    <dl>
      
      <dt class="tab_dt">注册</dt>
      <dd class="tab_dd">
        <script type="text/javascript" src="http://www.zzjs.net/ad/tc.js"></script>
        <font color="red">&nbsp<@s.fielderror /></font>
        <@s.actionerror />
        <form id="registerForm" class="www_zzjs_net" method="post" action="${base}/user/register.action">
          <p class="input">
            <label for="username">昵称</label>
            <input type="text" required="required"  class="required" aria-required="true" tabindex="1" size="12" id="username2" name="user.username" placeholder="注册成功后用户名不可更改" onchange=oneditName() />
            <span id="tip1">
          </p>
          <p class="input">
            <label for="email">邮箱</label>
            <input type="text" required="required" class="required" aria-required="true" tabindex="1" size="12" id="email2" name="user.email" placeholder="请填写有效邮箱" onchange=oneditEmail() />
            <span id="tip2">
          </p>
          </p>
          <p class="input">
            <label for="password">密码</label>
            <input type="password" required="required" class="required" aria-required="true" tabindex="2" size="12"  id="password2" name="user.password">
          </p>
          <p class="input">
            <label for="repassword">确认密码</label>
            <input type="password" required="required" class="required" aria-required="true" tabindex="2" size="12"  id="repassword2" name="repassword">
          </p>
          <p class="input">
            <input type="submit" value="注册" tabindex="5" class="submit" id="submit" name="submit">
            <input type="reset" value="取消" class="submit"tabindex="5" id="cancel" name="cancel" />
          </p>
        </form>
      </dd>
    </dl>
  </div>
</div>
<@html.bottom>
  <!--请不要在此处添加内容-->
</@html.bottom>
</body>
</html>
